package com.cy.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;

/**
 * <p>Description: [后台用户权限]</p>
 * @author         [曹悦] 
 */
@Entity
@Table(name = "CY_BACK_PURVIEW")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true )
public class BackPurview implements Serializable{

	private static final long serialVersionUID = -1529331660954169915L;
	private Long id;
	
	private String name;								//权限名
	private String actionName;							//权限路径
	private BackPurview parent;							//上级的权限
	private String sortTree;							//序号由最上级到本级的连串，用于排序查询
	private int sortNo;								//序号
	private int level;									//等级
	private NormalStatus status; 						//状态
	
	
	private int isSelect=0;   							//是否选中  默认不选中
	
	@Id
	@SequenceGenerator(name = "CY_BACK_PURVIEW_SEQ", sequenceName = "CY_BACK_PURVIEW_SEQ",allocationSize=1,initialValue=1)
	@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "CY_BACK_PURVIEW_SEQ")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(length=50,name="name",nullable=false)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(length=255,name="actionName")
	public String getActionName() {
		return actionName;
	}
	public void setActionName(String actionName) {
		this.actionName = actionName;
	}
	
	@ManyToOne(optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id", nullable = true)
	public BackPurview getParent() {
		return parent;
	}
	public void setParent(BackPurview parent) {
		this.parent = parent;
	}	
	
	@Column(name = "level_")
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}

	@Column(length=50 ,name = "sortTree")
	public String getSortTree() {
		return sortTree;
	}
	public void setSortTree(String sortTree) {
		this.sortTree = sortTree;
	}
	
	@Column(name = "sort_No")
	public int getSortNo() {
		return sortNo;
	}
	public void setSortNo(int sortNo) {
		this.sortNo = sortNo;
	}
	
	@Transient
	public int getIsSelect() {
		return isSelect;
	}
	public void setIsSelect(int isSelect) {
		this.isSelect = isSelect;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final BackPurview other = (BackPurview) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	@Type(type="com.cy.entity.NormalStatusUserType")
	public NormalStatus getStatus() {
		return status;
	}
	
	public void setStatus(NormalStatus status) {
		this.status = status;
	}
	

	
	
	
}
